﻿using System;
using System.ComponentModel;
using System.Data.Services.Common;
using System.Runtime.Serialization;

namespace Kinban.Contracts
{
    //[DataServiceKey("Id")]
    //[DataContract(Name = "Story")]
    //[EntitySet("Story")]
    public class Story : INotifyPropertyChanged
    {
        #region Description (INotifyPropertyChanged Property)
        private string _description;
        [DataMember]
        public string Description
        {
            get { return _description; }
            set
            {
                if (_description != value)
                {
                    _description = value;
                    OnPropertyChanged("Description");
                }
            }
        }
        #endregion

        #region Id (INotifyPropertyChanged Property)
        private int _id;
        [DataMember]
        public int Id
        {
            get { return _id; }
            set
            {
                if (_id != value)
                {
                    _id = value;
                    OnPropertyChanged("Id");
                }
            }
        }
        #endregion

        #region StartDate (INotifyPropertyChanged Property)
        private DateTime? _startDate;
        [DataMember]
        public DateTime? StartDate
        {
            get { return _startDate; }
            set
            {
                if (_startDate != value)
                {
                    _startDate = value;
                    OnPropertyChanged("StartDate");
                }
            }
        }
        #endregion

        #region EndDate (INotifyPropertyChanged Property)
        private DateTime? _endDate;
        [DataMember]
        public DateTime? EndDate
        {
            get { return _endDate; }
            set
            {
                if (_endDate != value)
                {
                    _endDate = value;
                    OnPropertyChanged("EndDate");
                }
            }
        }
        #endregion

        #region StackRank (INotifyPropertyChanged Property)
        private double? _stackRank;
        [DataMember]
        public double? StackRank
        {
            get { return _stackRank; }
            set
            {
                if (_stackRank != value)
                {
                    _stackRank = value;
                    OnPropertyChanged("StackRank");
                }
            }
        }
        #endregion

        #region DescriptionLong (INotifyPropertyChanged Property)
        private string _descriptionLong;
        [DataMember]
        public string DescriptionLong
        {
            get { return _descriptionLong; }
            set
            {
                if (_descriptionLong != value)
                {
                    _descriptionLong = value;
                    OnPropertyChanged("DescriptionLong");
                }
            }
        }
        #endregion

        //[DataMember]
        //public string AssignedToId { get; set; }

        #region AssignedTo (INotifyPropertyChanged Property)
        private string _assignedTo;
        [DataMember]
        public string AssignedTo
        {
            get { return _assignedTo; }
            set
            {
                if (_assignedTo != value)
                {
                    _assignedTo = value;
                    OnPropertyChanged("AssignedTo");
                }
            }
        }
        #endregion

        #region State (INotifyPropertyChanged Property)
        private string _state;
        [DataMember]
        public string State
        {
            get { return _state; }
            set
            {
                if (_state != value)
                {
                    _state = value;
                    OnPropertyChanged("State");
                }
            }
        }
        #endregion
        
        #region ErrorOccurred (INotifyPropertyChanged Property)
        private bool _errorOccurred;
        [DataMember]
        public bool ErrorOccurred
        {
            get { return _errorOccurred; }
            set
            {
                if (_errorOccurred != value)
                {
                    _errorOccurred = value;
                    OnPropertyChanged("ErrorOccurred");
                }
            }
        }
        #endregion

        #region ErrorMessage (INotifyPropertyChanged Property)
        private string _errorMessage;
        [DataMember]
        public string ErrorMessage
        {
            get { return _errorMessage; }
            set
            {
                if (_errorMessage != value)
                {
                    _errorMessage = value;
                    OnPropertyChanged("ErrorMessage");
                }
            }
        }
        #endregion

        #region ProjectName (INotifyPropertyChanged Property)
        private string _projectName;
        [DataMember]
        public string ProjectName
        {
            get { return _projectName; }
            set
            {
                if (_projectName != value)
                {
                    _projectName = value;
                    OnPropertyChanged("ProjectName");
                }
            }
        }
        #endregion
        
        #region ProjectCollectionUrl (INotifyPropertyChanged Property)
        private string _projectCollectionUrl;
        [DataMember]
        public string ProjectCollectionUrl
        {
            get { return _projectCollectionUrl; }
            set
            {
                if (_projectCollectionUrl != value)
                {
                    _projectCollectionUrl = value;
                    OnPropertyChanged("ProjectCollectionUrl");
                }
            }
        }
        #endregion

        #region INotifyPropertyChanged values

        /// <summary>
        /// Event definition for INotifyPropertyChanged.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        public void OnPropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion
    }
}